//
// Created by 束庆乐 on 2025/1/7.
//
#include "iostream"
#include "vector";
#include "algorithm"
using namespace std;

void test(){
    vector<int> v1;
    for (int i = 0; i < 10; ++i) {
        v1.push_back(i);
    }
    for (int i = 0; i < v1.size(); i++) {
        cout << v1[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < v1.size(); ++i) {
        cout << v1.at(i) << " ";
    }
    cout << endl;
    cout << "v1 first ele is:" << v1.front() << endl;
    cout << "v1 last ele is:" << v1.back() << endl;

    vector<int> v2;
    for (int i = 0; i < 5; ++i) {
        v2.push_back(0);
    }
    v2.swap(v1);
    for (int i = 0; i < v1.size(); ++i) {
        cout << v1.at(i) << " ";
    }
    cout << endl;
    for (int i = 0; i < v2.size(); ++i) {
        cout << v2.at(i) << " ";
    }
}

void test2(){
    vector<int> v;
    for (int i = 0; i < 10000; ++i) {
        v.push_back(i);
    }

    cout << "v capacity :" << v.capacity() << endl;
    cout << "v size" << v.size() << endl;

    v.resize(3);
    cout << "v capacity :" << v.capacity() << endl;
    cout << "v size" << v.size() << endl;
    v.push_back(200);
    //收缩内存
    vector<int>(v).swap(v);//匿名对象
    cout << "v capacity :" << v.capacity() << endl;
    cout << "v size" << v.size() << endl;

}

int main122(){
//    test();
test2();
    return 0;
}